package org.dromara.oce.service.inner.impl;

import cn.hutool.http.HttpUtil;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.dromara.oce.config.DsdjConfig;
import org.dromara.oce.service.inner.DsdjServeRemoteService;
import org.dromara.oce.utils.PlatformConstants;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

@Service
@AllArgsConstructor
@Slf4j
public class DsdjServeRemoteServiceImpl implements DsdjServeRemoteService {

    private final DsdjConfig dsdjConfig;

    @Override
    public String getAccessToken(String platformType, String appCode) {
        String url = dsdjConfig.getDsdjServerReqeustUrl() + "/app/third/getAccessToken" + "?platform=" + platformType + "&appCode=" + appCode;
        return HttpUtil.get(url);
    }

    @Override
    @Async
    public void deleteReferralIdListCache(Integer referralLinkType) {
        log.info("通知短剧服务清空推广链接缓存");
        HttpUtil.get(dsdjConfig.getDsdjServerReqeustUrl() + "/system/inner/deleteReferralIdListCache" + "?platformType=" + PlatformConstants.JULIANG + "&referralLinkType=" + referralLinkType);
    }
}
